<!-- $Id: bonus_type_info.htm 14216 2008-03-10 02:27:21Z testyang $ -->
<script language="javascript" type="text/javascript" src="../js/DatePicker/WdatePicker.js"></script>
{include file="pageheader.htm"}
<div class="main-div">
<form action="luckdraw.php" method="post" name="theForm" enctype="multipart/form-data" onsubmit="return validate()">
<table width="100%" id="general-table">
  <tr>
    <td class="label">抽奖标题：</td>
    <td>
      <input type='text' name='title'  value="{$goods.title}" size='50' /></td>
  </tr>
  
  <tr>
      <td align="right">关键字：</td>
      <td><input type="text" name="keywords" size="30" />
      <input type="button" value="搜索" class="button" onclick="searchGoods()" {if $form_action eq 'update'} disabled="true" {/if}></td>
    </tr>
   <tr>
    <td class="label">参与抽奖商品：</td>
    <td>
    	  <select name="goods_id">
        {$goods.option}
        </select>
        <span class="notice-span" style="color:#F00;">仅限设置限购数量为1的拼团商品</span>
    </td>
  </tr>

  <tr>
    <td class="label">中奖库存：</td>
    <td>
    	<input type="text" value="{$goods.stock_num}"  name="stock_num"  >
       <span class="notice-span">一次抽奖活动中奖商品库存数量（人数），设置抽奖的商品请先设置此商品限购数量为1</span>
    </td>
  </tr>
 
  <tr>
    <td class="label">活动开始时间：</td>
    <td>
      <input class="Wdate" name="start_time" type="text" size="20" value='{$goods.start_time}' readonly="readonly" onfocus="WdatePicker({dateFmt:'yyyy-M-d HH:mm'})"/></td>
  </tr>
  <tr>
    <td class="label">活动截止时间：</td>
    <td>
      <input class="Wdate" name="end_time" type="text" size="20" value='{$goods.end_time}' readonly="readonly" onfocus="WdatePicker({dateFmt:'yyyy-M-d HH:mm'})"/></td>
  </tr>
  
  
  <tr>
    <td class="label">简单描述：</td>
    <td>
    
    
<textarea name="content" cols="50" rows="5">{$goods.content}</textarea>      
      
      </td>
  </tr>
  
  <tr>
    <td class="label">&nbsp;</td>
    <td>
      <input type="submit" value="{$lang.button_submit}" class="button" />
      <input type="reset" value="{$lang.button_reset}" class="button" />
      
      <input type="hidden" name="id" value="{$goods.id}" />
      
      <input type="hidden" name="act" value="{$form_action}" />
     <span class="notice-span" style="color:#F00;">抽奖活动开始后不宜修改开始时间和结束时间</span>
    </td>
  </tr>
</table>
</form>
</div>
{insert_scripts files="../js/utils.js,validator.js"}
{literal}
<script language="javascript">
<!--
document.forms['theForm'].elements['type_name'].focus();
/**
 * 检查表单输入的数据
 */
function validate()
{
  validator = new Validator("theForm");
  
  validator.required("title",      '标题不能为空');
  validator.required("goods_id",    '请选择抽奖商品');
  validator.required("stock_num",    '请设置中奖库存');
  validator.required("start_time",    '活动开始时间不能为空');
	validator.required("end_time",    '活动结束时间不能为空');
  
  return validator.passed();
}
function searchGoods()
{
    var filter = new Object;
    filter.keyword = document.forms['theForm'].elements['keywords'].value;    filter.is_team = 1;
    filter.is_zero = 0;    filter.is_miao = 0;    filter.is_luck = 0;    filter.limit_buy_bumber = 1;
    Ajax.call('luckdraw.php?is_ajax=1&act=search_goods', filter, searchGoodsResponse, 'GET', 'JSON')
}

function searchGoodsResponse(result)
{
  var frm = document.forms['theForm'];
  var sel = frm.elements['goods_id'];

  if (result.error == 0)
  {
    /* 清除 options */
    sel.length = 0;

    /* 创建 options */
    var goods = result.content;
    if (goods)
    {
        for (i = 0; i < goods.length; i++)
        {
            var opt = document.createElement("OPTION");
            opt.value = goods[i].goods_id;
            opt.text  = goods[i].goods_name;
            sel.options.add(opt);
        }
    }
    else
    {
        var opt = document.createElement("OPTION");
        opt.value = 0;
        opt.text  = search_is_null;
        sel.options.add(opt);
    }
  }

  if (result.message.length > 0)
  {
    alert(result.message);
  }
}
//-->
</script>
{/literal}
{include file="pagefooter.htm"}
